import Service.Main;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;

import java.io.IOException;
import java.net.Socket;
import java.net.URL;
import java.sql.SQLException;

public class TestController {

    @FXML
    private Button registerButton;

    @FXML
    private Button closeButton;

    @FXML
    private Button loginButton;

    @FXML
    private Text wellcome_Text;

    @FXML
    private AnchorPane startStage;

    private static Stage stage;

    public TestController() throws SQLException {
    }

    public static Stage getStage() {
        return stage;
    }

    private static void setStage(Stage stage) {
        TestController.stage = stage;
    }

    Socket socket;

    public Socket getSocket() {
        return socket;
    }


    @FXML
    void registerAction(ActionEvent event) throws IOException {
        Main.primaryStage.close();
        URL url1 = getClass().getResource("helios/fxml/register.fxml");
        Parent root=FXMLLoader.load(url1);
        Scene scene = new Scene(root,619,486);
        Stage stage = new Stage();
        stage.setResizable(false);
        stage.setTitle("login");
        stage.setScene(scene);
        stage.show();
    }

    @FXML
    void login(MouseEvent event) {

    }

    @FXML
    void loginAction(ActionEvent event) throws IOException {

        Main.primaryStage.close();
        URL url = getClass().getResource("helios/fxml/login.fxml");
        Parent root=FXMLLoader.load(url);
        Scene scene = new Scene(root,600,400);
        Stage stage = new Stage();
        stage.setResizable(false);
        stage.setTitle("登录");
        stage.setScene(scene);
        stage.show();
    }

    @FXML
    void register(MouseEvent event) {

    }

    @FXML
    void closeAction(ActionEvent event) {
        Stage stage = (Stage) closeButton.getScene().getWindow();
        stage.close();
    }

    @FXML
    void close(MouseEvent event) {

    }

}
